package com.lincoln.redis.server.entity;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户前台模型
 * @author lincoln
 */
@Data
public class UserVo {
    /**
     * 用户名
     */
    private String username;

    public UserVo(User user) {
        if (user == null) {
            throw new RuntimeException("user = null");
        }
        this.username = user.getUsername();
    }

    public static List<UserVo> formatList(List<User> userList){
        List<UserVo> res = new ArrayList<>();
        for(User user:userList){
            res.add(new UserVo(user));
        }
        return res;
    }
}
